package com.kitbox.hl.meshow.bpm.web;

import com.goshine.sgcloud.platform.common.rest.ResponseWapper;
import com.goshine.sgcloud.platform.common.rest.SucceedWapper;
import com.kitbox.hl.meshow.bpm.bean.BPMWorkItem;
import com.kitbox.hl.meshow.bpm.bean.WFActivityInst;
import com.kitbox.hl.meshow.bpm.service.IBpmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @Auther: honglei
 * @Date: 2019/9/2 16:59
 * @Description:
 */
@RestController
@RequestMapping("/api/bpm/")
public class BPMController {

    @Autowired
    private IBpmService bpmService;

    @RequestMapping(value = "createProcessInstance",method = {RequestMethod.GET,RequestMethod.POST})
    public String createProcessInstance(String userID, String processDefName, String processInstName, String processInstDesc, Boolean isStart) throws Exception {
        return bpmService.createProcessInstance("demo","leave","20180521Loan10","请假流程》=3天",true);

    }


    public List<BPMWorkItem> queryPersonWorkItems(String userID, String personID, String permission, String scope) throws Exception {
        return null;
    }


    public String appointActivityParticipant(String userId, long workItemID, String activityDefID, String participantsxml) throws Exception {
        return null;
    }


    public String assignWorkItemToSelf(String userID, long workItemid) throws Exception {
        return null;
    }


    public String assignAndFinishWorkItemWithOption(String userID, long workItemid, String relativeData, boolean checkPermission) throws Exception {
        return null;
    }


    public List<BPMWorkItem> queryPersonFinishedWorkItems(String userID, String personID, String permission, Boolean includeHistory) throws Exception {
        return null;
    }


    public List<BPMWorkItem> queryWorkItemsAndReviewByProcessInstId(long ProcessInstId, Boolean includeHistory) throws IOException {
        return null;
    }


    public List<BPMWorkItem> queryPersonAllWorkItems(String userID, String personID, String permission, String scope, Boolean includeHistory, long processInstID) throws Exception {
        return null;
    }


    public List<BPMWorkItem> queryBacklogAndFinishWorkItemsByProcessInstId(String ProcessInstId, boolean includeHistory) throws Exception {
        return null;
    }


    public void finishActivityInstance(String userID, long activityInstID) throws Exception {

    }


    public String finishWorkItemWithOption(String userID, long workItemid, String relativeData, boolean checkPermission) throws Exception {
        return null;
    }


    public String batchReassignWorkItem(String userID, String jsonStr) throws Exception {
        return null;
    }


    public WFActivityInst queryPreviousActivityInstances(String userID, long activityInstID) throws Exception {
        return null;
    }


    public void backActivity(String userId, long currentActInstID, long destActInstID, String rollBackStrategy) throws Exception {

    }


    public void backDefActivity(String userId, long currentActInstID, String destActDefID, String rollBackStrategy) throws Exception {

    }


    public String changeProcessInstState(String userID, long processInstID, int destState) throws Exception {
        return null;
    }


    public String terminateProcessInstance(String userID, long processInstID) throws Exception {
        return null;
    }


    public String getActivityInstState(String userID, long activityInstID) throws Exception {
        return null;
    }


    public String removeActivityInstance(String userID, long actInstID) throws Exception {
        return null;
    }


    public void restartActivityInstance(String userID, long activityInstID) throws Exception {

    }


    public void resumeActivityInstance(String userID, long activityInstID) throws Exception {

    }


    public void suspendActivityInstance(String userID, long activityInstID) throws Exception {

    }


    public void terminateActivityInstance(String userID, long activityInstID) throws Exception {

    }




    public String getProcessInstState(String userID, long processInstID) throws Exception {
        return null;
    }



    @RequestMapping(value = "getProcess",method = {RequestMethod.GET,RequestMethod.POST})
    public ResponseWapper getProcess(String userID, long processDefID) throws Exception {

        if (userID==null)
            userID="tiger";
        return new SucceedWapper(bpmService.getProcess(userID,processDefID));


    }
}
